package com.hzqy.service.industry;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.industry.IndustryThresholdDao;
import com.hzqy.web.vo.CmContentVo;
import com.hzqy.web.vo.industry.threshold.IndustryThresholdVideo;
@Service
public class IndustryThresholdServiceBean{
	@Resource
	private IndustryThresholdDao industryThresholdDao;
	public Map<String,Object> selectThresholdList(IndustryThresholdVideo industryThresholdVideo) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = industryThresholdDao.selectThresholdListCount(industryThresholdVideo);
		map.put("total", rowCount);
		if(rowCount > 0 && industryThresholdVideo.getPage() > 0 && industryThresholdVideo.getRows() > 0) {
			map.put("firstResult", (industryThresholdVideo.getPage())*industryThresholdVideo.getRows());
			map.put("maxResults", industryThresholdVideo.getRows());
			List<IndustryThresholdVideo> results = industryThresholdDao.selectThresholdList(industryThresholdVideo);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<CmContentVo>());
		}
		return map;
	}
	public Map<String,Object> addThreshold(IndustryThresholdVideo industryThresholdVideo) {
		Map<String,Object> resultMap = new HashMap<String,Object>();
		int flag=industryThresholdDao.addThreshold(industryThresholdVideo);
		if(flag>0){
			resultMap.put("success", true);
			resultMap.put("result","新增阀值成功!");
		}else{
			resultMap.put("success", false);
			resultMap.put("result","新增阀值失败!");
		}
		return resultMap;
	}
	public Map<String, Object> deleteThreshold(int f_itv_id) {
		Map<String,Object> resultMap = new HashMap<String,Object>();
		int flag=industryThresholdDao.deleteThreshold(f_itv_id);
		if(flag>0){
			resultMap.put("success", true);
			resultMap.put("result","删除阀值成功!");
		}else{
			resultMap.put("success", false);
			resultMap.put("result","删除阀值失败!");
		}
		return resultMap;
	}
	public Map<String, Object> updateThreshold(IndustryThresholdVideo industryThresholdVideo) {
		Map<String,Object> resultMap = new HashMap<String,Object>();
		int flag=industryThresholdDao.updateThreshold(industryThresholdVideo);
		if(flag>0){
			resultMap.put("success", true);
			resultMap.put("result","更新阀值成功!");
		}else{
			resultMap.put("success", false);
			resultMap.put("result","更新阀值失败!");
		}
		return resultMap;
	}
	public IndustryThresholdVideo selectThresholdInfo(int f_itv_id) {
		return industryThresholdDao.selectThresholdInfo(f_itv_id);
	}
	public Map<String, Object> clearThreshold() {
		Map<String,Object> resultMap = new HashMap<String,Object>();
		int flag=industryThresholdDao.clearThreshold();
		if(flag>0){
			resultMap.put("success", true);
			resultMap.put("result","清空阀值成功!"+flag);
		}else{
			resultMap.put("success", false);
			resultMap.put("result","清空阀值失败!");
		}
		return resultMap;
	}
}